/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id$ 
#
# $Author$ 
#
# $Revision$ 
#
# $Date$ 
#
# Description: 
#
=============================================================================*/
#include	"rtos-wsn.h"
#include	"wsn-rf.h"

extern void  platform_wsn_init(void);
extern void wsn_start_timer(void);
extern void wsn_app_start(void);
extern void wsn_zigbee_start(void);



/************************************************************************
 *
 *  System Entry
 *
 ************************************************************************
 */

int wsn_start(void)
{
    /* Set disable sched flag */
    wsn_disable_sched = SCHED_LOCK;

    /* Initialize task structure */
    wsn_task_init();
#ifdef _Debug_thread_
    wsn_thread_init();
#endif
	wsn_backtask_init();
    wsn_timer_init();

    /* Init the platform RTOS */
    platform_wsn_init();

    /* Enable  interrupt */
    wsn_LeaveCritical();

    /* Start the timer */
    wsn_start_timer();

    /* Start Application */

#ifdef _Debug_thread_
	
			/** ********************COMMOND LIST******************** **/
			WSN_debug(0x02ea, 0);
			/** PRESS  '0': stop   ALL				 **/
			WSN_debug(0x02eb, 0);
			/** PRESS  '1': start  ALL				 **/
			WSN_debug(0x02ec, 0);
			/** PRESS  '2': start  BLINK			 **/
			WSN_debug(0x02ed, 0);
			/** PRESS  '3': start  BLINK_TO_RADIO	 **/
			WSN_debug(0x02ee, 0);
			/** PRESS  '4': start  THREAD_&_EVENT	 **/
			WSN_debug(0x02ef, 0);
			/** PRESS  '5': start  TASK_APP    **/
			WSN_debug(0x02f0, 0);
			/** ********************COMMOND LIST******************** **/
			WSN_debug(0x02f1, 0);
			/** Now, your choice ...  **/
			WSN_debug(0x02f2, 0);
			
			//rf_on(); 
			//rf_osc_on(); 
	
			wsn_app_start();
#else	
			/* Start zigbee */
			wsn_zigbee_start();
#endif


    while ( 1 ) {
        wsn_sched();
    }
	
}



